$(document).ready(function() {
	$("#modifyRequestByAgent").validate({
		rules: {
			event_owner:{
				required: true,
				minlength: 2
			}
			/*event_usertype: "required",			
			event_type: "required",
			event_status: "required",
			event_emergency: "required",
			event_influencearea: "required",
			event_priority: "required",
			event_addtime: {
				date: true
			},
			event_source: "required",
			event_category: "required",
			event_subclass: "required",
			event_title: {
				required: true,
				minlength: 5
			},
			
			event_desc: {
				required: true,
				minlength: 10
			},
			event_influencebusiness: {
				required: true,
				minlength: 5
			}*/
		},
		messages: {
			event_owner: {
				required: "用户不能为空",
				minlength: "用户名不能少于2个字符"
			},
			event_addtime: {
				date: "必须输入正确格式的日期"
			},
			event_title: {
				required: "主题不能为空",
				minlength: "主题不能少于5个字符"
			},
			event_desc: {
				required: "描述不能为空",
				minlength: "描述不能少于10个字符"
			},
			event_influencebusiness: {
				required: "影响业务描述不能为空",
				minlength: "影响描述不能少于5个字符"
			}
		}
	});

	$("select[name='event_category']").change(function() {
		var url = "/index.php/incident/getSubclass";
		var event_category	= $(this).val();
		var option_type		= 'event_category';
	
		$.ajax({
			url: url,
			dataType: 'json',
			data: { event_category: event_category, option_type:option_type, s:Math.random() },
			type: 'post',
			success: function(ret) {
				var html = '';
				for(var o in ret) {
					html	+= '<option value="'+ret[o].option_id+'">'+ret[o].option_name+'</option>';
				}
				if (html != '')
				{ 
					$("select[name='event_subclass']").html(html);
				}
			}
		});
	});
	
});